package exception;

/**
 * 测试异常地抛出
 */
public class Student {
    private int age;

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws IllegalAgeException{
        if (age>100||age<0){
            throw new IllegalAgeException("年龄不合法");
        }
        this.age = age;
    }

    Student(){

    }

    public Student(int age) throws IllegalAgeException{
        if (age>100||age<0){
            throw new IllegalAgeException("年龄不合法");
        }
        this.age = age;
    }
}
